/**
 * 
 */
package net.dntuan.training.spring.mvc;

import net.dntuan.training.spring.integration.Message;
import net.dntuan.training.spring.integration.MessageGateway;
import net.dntuan.training.spring.integration.Result;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author tuan.dangnhu
 *
 * <br>$LastChangedRevision: 117 $
 * <br>$LastChangedDate: 2014-07-16 15:36:00 +0000 (Wed, 16 Jul 2014) $
 */
@Controller
@RequestMapping("api")
public class MessageController {

  private static final Logger LOGGER = LoggerFactory.getLogger(MessageController.class);

  @Autowired
  private MessageGateway messageGateway;

  @RequestMapping(value = "print-log")
  @ResponseBody
  public Result printLog(String content) {
    Message msg = new Message();
    msg.setStartTime(System.currentTimeMillis());
    msg.setContent(content);
    LOGGER.info("request: " + content);
    return messageGateway.send(msg);
  }
}
